package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.Campsite;
import com.ruoyi.camp.service.ICampsiteService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/wechat/campsite")
public class WxCampsiteController extends BaseController
{
    @Autowired
    private ICampsiteService campsiteService;

    /**
     * 查询营位列表
     */
    @GetMapping("/list")
    public AjaxResult list(Campsite campsite) {
        List<Campsite> list  = campsiteService.selectCampsiteList(campsite);
        return success(list);
    }
    /**
     * 获取营位详细信息
     */
    @GetMapping(value = "/{campsiteid}")
    public AjaxResult getInfo(@PathVariable("campsiteid") String campsiteid)
    {
        return success(campsiteService.selectCampsiteByCampsiteid(campsiteid));
    }
    /**
     * 新增营位
     */
    @PostMapping
    public AjaxResult add(@RequestBody Campsite[] campsite)
    {

        return toAjax(campsiteService.insertCampsite(campsite));
    }

    /**
     * 修改营位
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Campsite campsite)
    {
        return toAjax(campsiteService.updateCampsite(campsite));
    }

    /**
     * 删除营位
     */
    @DeleteMapping("/{campsiteid}")
    public AjaxResult remove(@PathVariable String campsiteid)
    {
        return toAjax(campsiteService.deleteCampsiteByCampsiteid(campsiteid));
    }
}
